package com.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.model.DocumentDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DocumentDetailMapper extends BaseMapper<DocumentDetail> {
    @Select("SELECT *\n" +
            "FROM\n" +
            "(\n" +
            "SELECT s3.* \n" +
            "FROM \n" +
            "(\n" +
            "SELECT *\n" +
            "FROM document_summary s1\n" +
            "WHERE s1.search_keyword LIKE CONCAT('%', #{type}, '%')\n" +
            "AND DATE(s1.release_time) >= DATE(#{startTime})\n" +
            "AND DATE(s1.release_time) <= DATE(#{endTime})\n" +
            ") s\n" +
            "LEFT JOIN document_detail s3\n" +
            "ON s.id = s3.sid\n" +
            ") s4 \n" +
            "WHERE s4.id IS NOT NULL")
    List<DocumentDetail> query(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") String type);

}
